﻿Imports System.Timers
Imports System.Collections

Public Class Sprite

    Public Sub New()
    End Sub

    Public Sub New(ByVal Name As String, ByVal ID As Vector4, ByVal SpawnTimer As Integer)
        Stats = New Stats
        Stats.Name = Name
        Stats.SpawnLoc = ID
        Stats.SpawnTimer = SpawnTimer
    End Sub

    Public Sub New(ByVal Name As String, ByVal Stats As Stats)
        Me.Stats = New Stats
        Me.Stats = Stats
        Me.Stats.Name = Name
    End Sub

    Public Sub New(ByVal Name As String, ByVal SpawnTimer As Integer) 'Spawn code
        Stats = New Stats
        Stats.Name = Name
        Stats.SpawnTimer = SpawnTimer
    End Sub

    Public Sub Attack(ByRef Target As Sprite) 'AI CODE HERE
        If attackTimer.Enabled = False Then
            attackTimer.Interval = Stats.Delay * 100
            attackTimer.Enabled = True
            Me.Target = Target
        End If
    End Sub

    Public Sub AttackTimerTick() Handles attackTimer.Elapsed
        Dim DamageDealt As Integer = Random.Next(0, (Stats.Level * Stats.Damage) + Stats.Level)
        a.Invoke(Me, DamageDealt)
        Target.Stats.HP -= DamageDealt
        If Target.Stats.HP <= 0 Then
            Target.IsDead = True
            Target.Stats.HP = 0
            attackTimer.Stop()
            Target.attackTimer.Stop()
        End If
    End Sub

End Class

'Public Sub New(ByRef Sprite As Sprite) 'Used in converting a player to sprite
'    With Sprite
'        HP = .HP
'        HPMax = .HPMax
'        Energy = .Energy
'        EnergyMax = .EnergyMax
'        Stamina = .Stamina
'        StaminaMax = .StaminaMax
'        Name = .Name
'        Level = .Level
'        Weapon = .Weapon
'        Damage = .Damage
'        Delay = .Delay
'    End With
'End Sub